package core

import (
	"fmt"
	"go.uber.org/zap"
	"go_es/server/global"
	"go_es/server/initialize"
	"go_es/server/process"
	"time"
)

type server interface {
	ListenAndServe() error
}

func RunWindowsServer()  {
	// 初始化redis服务
	initialize.Redis()
	//初始化elastic
	initialize.Elastic()
	Router := initialize.Routers()
	address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
	s := initServer(address, Router)
	time.Sleep(10 * time.Microsecond)
	global.GVA_LOG.Info("server run success on ", zap.String("address", address))
	fmt.Printf(address)

	//开启常驻进程
	process.ProcessGroupApp.InsertEs()
	global.GVA_LOG.Error(s.ListenAndServe().Error())
}